package com.turing.data.scripts.contract.transfer

import com.turing.data.vo.out.review.DependParamsVO
import com.turing.data.vo.out.review.TaskElementVO


class Range_30171_10_transfer {

    static List< TaskElementVO.DrawResultVO > doConvert(List< TaskElementVO.DrawResultVO > resultVOs, DependParamsVO dependParams){

        for( drawResultVO in resultVOs ){
                def childTaskSn = drawResultVO.childTaskSn
                if(null == childTaskSn || childTaskSn == ""){
                    continue
                }
            String modelValue = drawResultVO.text

            String REGEX_NOT_LESS_THAN = /.*不.*低于.*[0-99]%.*/
            String REGEX_NOT_LESS_THAN_2 = /.*得低于.*[0-99]%.*/

            modelValue = modelValue.replaceAll("\n", "").replaceAll("\r", "")\
                                        .replaceAll("【","").replaceAll("】","")
            println modelValue
            if(modelValue =~ REGEX_NOT_LESS_THAN || REGEX_NOT_LESS_THAN_2){
                Integer[] numbers = modelValue.findAll(/\d+/)*.toInteger()
                int range = 0
                for(num in numbers){
                    range = num
                }
                if(range>80){
                    range=80
                }
                drawResultVO.businessValue =  range + "%至100%"
                drawResultVO.type = 1
                continue
            }

            String REGEX_MORE_THAN_1 = /.*超过.*[0-99]%.*/;
            String REGEX_MORE_THAN_2 = /.*高于.*[0-99]%.*/;

            if(modelValue =~ REGEX_MORE_THAN_1 || modelValue =~ REGEX_MORE_THAN_2){
                Integer[] numbers = modelValue.findAll(/\d+/)*.toInteger()
                int range = 0
                for(num in numbers){
                    range = num
                }
                drawResultVO.businessValue = range + "%至100%"
                drawResultVO.type = 1
                continue
            }
            if(modelValue =~ /\d%-100%/){
                Integer[] numbers = modelValue.findAll(/\d+/)*.toInteger()
                int range = 0
                for(num in numbers){
                    range = num
                    break
                }
                drawResultVO.businessValue = range + "%至100%"
                drawResultVO.type = 1
                continue
            }
            drawResultVO.businessValue = ""

        }

        return resultVOs
    }

    public static void main(String[] args) {
        String REGEX_NOT_LESS_THAN = /.*不低于.*[0-99]%.*/
        String a = "不低于资产管理计划总资产\n" +
                "的 80%"
        if( a =~ REGEX_NOT_LESS_THAN){
            println 111
        }
    }

}
